<%@page import="com.yymmarket.forum.util.*,com.yymmarket.forum.user.*,com.yymmarket.framework.WebAction"%><%@ 
page contentType="text/vnd.wap.wml;charset=utf-8"%><%
response.setHeader("Cache-Control","no-cache");
WebAction webAction = new WebAction(request,response);
String method = request.getMethod().toUpperCase();
if(method.equals("POST")) {
	String account = webAction.getParameterString("a");
	if(account==null||account.trim().length()==0) {
		response.sendRedirect("register.jsp?msg=account-noNull");
		return;
	} else if(account.trim().length()<5&&account.trim().length()>20) {
		response.sendRedirect("register.jsp?msg=account-noLength");
		return;
	}
	String password = webAction.getParameterString("p");
	if(password==null||password.length()==0) {
		response.sendRedirect("register.jsp?msg=password-noNull");
		return;
	}
	
	UserService userService = UserService.getInstance();
	
	UserBean userBean = userService.getUserByAccount(account);
	
	if(userBean == null) {
		response.sendRedirect("register.jsp?msg=login-failure");
		return;
	} else {
		if(userBean.getPassword().equals(password)) {
			SessionUtil.sessionCreate(request,ConstantUtil.USER_SESSION,userBean.getId());
			response.sendRedirect("../bbs/index.jsp");
			return;
		} else {
			response.sendRedirect("register.jsp?msg=login-failure");
			return;
		}
	}
	
}

%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="登录">
<p>
欢迎登录<br/>
<%=request.getParameter("msg") %><br/>
账号:<br/>
<input type="text" name="a" /><br/>
密码:<br/>
<input type="text" name="p"/><br/>
<anchor>登录<go href="login.jsp" method="post">
<postfield name="a" value="$a" />
<postfield name="p" value="$p" />
</go></anchor>
</p>
</card>
</wml>